package com.study.d025paint;

import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.geometry.Rectangle2D;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.GridPane;
import javafx.scene.paint.Color;
import javafx.scene.paint.Paint;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;

/** 颜色填充
*@description
*@author xtayhame
*date 2020年3月20日
*version
*since v1.0
*/
public class ColorMain extends Application{
	public static void main(String[] args) {
		launch(args);
	}

	@Override
	public void start(Stage stage) throws Exception {
		AnchorPane anchorPane = new AnchorPane();
		GridPane gridPane = new GridPane();
		gridPane.setVgap(5);
		gridPane.setHgap(6);

		for(int i=0;i<6;i++){
			for(int k=0;k<5;k++){
				Rectangle rectangle = new Rectangle(70, 70);
				gridPane.add(rectangle, k, i);
				rectangle.setFill(Color.GRAY);
			}
		}

		ObservableList<Color> colorsList=FXCollections.observableArrayList();

		//设置颜色1
		colorsList.add(Color.valueOf("#FFB6C1"));

		colorsList.add(new Color(255/255, 50/255, 15/255, 0.5));

		colorsList.add(Color.BLUE);

		colorsList.add(Color.rgb(255, 50, 15));
		//设置透明  透明后为白色
		colorsList.add(Color.rgb(255, 50, 15, 1));

		colorsList.add(Color.grayRgb(230));

		colorsList.add(Color.web("#4B0082"));

		colorsList.add(Color.web("#1E90FF",0.5));

		colorsList.add(Color.hsb(200, 0.1, 0.6));



		if(colorsList.size() > 0){
			for(int i=0;i<colorsList.size();i++){
				System.out.println("-----------------"+i);
				Rectangle rectangle = (Rectangle)gridPane.getChildren().get(i);
				rectangle.setFill(colorsList.get(i));
			}
		}



		anchorPane.getChildren().add(gridPane);
		stage.setScene(new Scene(anchorPane, 500, 500));
		stage.show();
	}

}
